﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using ZPod.MTG;
using System.Collections;

namespace ZPod.MTG.Communication
{
	[DataContract]
	[Serializable]
	public class GameState
	{
		public GameState()
		{
			CommonCards = new List<Card>();
			Players = new Dictionary<String, PlayerState>(StringComparer.InvariantCultureIgnoreCase);
		}

		/// <summary>
		/// Diccionario NombreJugador -> Estado
		/// </summary>
		[DataMember]
		private Dictionary<String, PlayerState> Players
		{
			get;
			set;
		}

		/// <summary>
		/// Cartas en la zona "comun"
		/// </summary>
		[DataMember]
		public List<Card> CommonCards
		{
			get;
			set;
		}

		/// <summary>
		/// Jugadores activos en el juego
		/// </summary>
		public List<String> PlayerList
		{
			get
			{
				return Players.Keys.ToList();
			}
		}
		
		/// <summary>
		/// Establece el estado de un jugador
		/// </summary>
		/// <param name="player"></param>
		/// <param name="state"></param>
		public void SetState(string player, PlayerState state)
		{
			Players[player] = state;
		}

		/// <summary>
		/// Devuelve el estado de un jugador
		/// </summary>
		/// <param name="player"></param>
		/// <returns></returns>
		public PlayerState GetState(string player)
		{
			if (Players.ContainsKey(player))
			{
				return Players[player];
			}
			else
			{
				return null;
			}
		}
	}
}
